package net.bw.realtime.jtp.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.bw.realtime.jtp.bean.SkuAmountBean;
import org.bw.realtime.jtp.bean.SkuCntBean;
import org.bw.realtime.jtp.bean.SourceAmountBean;

import java.util.List;

@Mapper
public interface TradeSkuSourceMapper {

// -- 每日订单不同来源下单量、下单金额

	@Select("SELECT\n" +
			"      source_type_name\n" +
			"     -- 下单量\n" +
			"     , count(order_id) AS order_count\n" +
			"     -- 下单金额\n" +
			"     , sum(split_total_amount) AS order_amount\n" +
			"FROM jtp_mall_doris.dwd_order_detail\n" +
			"WHERE cur_date = #{date}\n" +
			"GROUP BY  cur_date,source_type_name")
	List<SourceAmountBean> selectSourceAmount(@Param("date")String date);

//	每日订单不同品牌分布 （商品销量）
	
	@Select("SELECT\n" +
			"     substring(sku_name,1,5) as sku_name\n" +
			"     , sum(sku_num) AS order_count\n" +
			"     , sum(split_total_amount) AS order_amount\n" +
			"FROM jtp_mall_doris.dwd_order_detail\n" +
			"WHERE cur_date = #{date}\n" +
			"GROUP BY cur_date, sku_name\n" +
			"order by order_count desc\n" +
			"limit 6")
	List<SkuCntBean> selectSkuCnt(@Param("date")String date);

//	每日订单销售品牌排名 (销售金额)
	@Select("SELECT\n" +
			"    substring(sku_name,1,5) as sku_name\n" +
			"     , sum(sku_num) AS order_count\n" +
			"     , sum(split_total_amount) AS order_amount\n" +
			"FROM jtp_mall_doris.dwd_order_detail\n" +
			"WHERE cur_date = #{date}\n" +
			"GROUP BY cur_date, sku_name\n" +
			"order by order_amount desc\n" +
			"limit 7")
	List<SkuAmountBean> selectSkuAmount(@Param("date")String date);

}
